package com.sise.stuteaintersys.bean.protocol;

import lombok.Data;
import com.sise.stuteaintersys.locallibs.enums.FileEnum;

/**
 * 返回体
 * @author
 * @param <DataType>
 */

@Data
public class NetResult<DataType> {
    /**
     *错误码 0:请求成功
     */
    private int code;
    /**
     * 消息
     */
    private String msg;
    /**
     * 数据体
     */
    private DataType data;

    /**s
     * 直接调用就行
     * @return
     */
    public NetResult() {}


    public static NetResult<String> netresultok(){
        return new NetResult<>(FileEnum.FILESUCCESS.getCode(), FileEnum.FILESUCCESS.getMessage(), "成功");
    }

    /**
     * 成功并加上data
     * @param code
     * @param msg
     * @param object
     * @return
     */
    public static NetResult okadddata(Integer code, String msg, Object object){
        return new NetResult<>(code, msg, object);
    }

    /**
     * 错误，写入code和msg
     * @param code
     * @param msg
     * @return
     */
    public static NetResult<String> error(Integer code, String msg){
        return new NetResult<>(code, msg);
    }

    public NetResult(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public NetResult(int code, String msg, DataType data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

}